<?php 

class Lemar_Basic
{
	
//-------------------------------------------------------------------------------------------------

	public static function ObjectToArray($object)
	{
		if(is_array($object) || is_object($object))
		{
			$array = array();
			foreach($object as $key => $value)
			{
				$array[self::UpperCaseToUnderline($key)] = self::ObjectToArray($value);
			}
			return $array;
		}
		return $object;
	}

//-------------------------------------------------------------------------------------------------

      
	public static function ArrayToObject($array = array())
	{
		return (object) $array;
	}	

//-------------------------------------------------------------------------------------------------
	
	public static function UpperCaseToUnderline($String)
	{
		$String[0] = strtolower($String[0]);
		
		for($i = "A"; strlen($i) == 1; $i++) //��������� "A"
		{
			$String = str_replace($i, '_' . strtolower($i)  , $String);
		}
		
		return $String;
	}
	
//-------------------------------------------------------------------------------------------------
	
	public static function CutStr($string)
	{
		$string = str_replace('https', '', $string);
		$string = str_replace('http', '', $string);
		$string = str_replace('://', '', $string);
		$string = str_replace('><', '> <', $string);
//		$string = str_replace('/', ' / ', $string);
		
		
		return $string;
	}

	//-------------------------------------------------------------------------------------------------
	
	public static function getCode()
	{
		$c1		= 	substr ((rand(10, 99999) * 10000), 0, 4);
		$c2		= 	substr ((rand(10, 99999) * 10000), 0, 4);
		$c3		= 	substr ((rand(10, 99999) * 10000), 0, 4);
		$c4		= 	substr ((rand(10, 99999) * 10000), 0, 4);
				
		
		return $c1 . '-' . $c2 . '-' . $c3 . '-' . $c4 ;
	}
	

//-------------------------------------------------------------------------------------------------
}